package com.one.consumer.reserve.ui.activity;

import android.content.Intent;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.one.common.config.RouterPath;
import com.one.common.view.base.IListView;
import com.one.common.view.widget.MyTitleBar;
import com.one.consumer.BaseListActivityC;
import com.one.consumer.reserve.model.extra.AreaExtra;
import com.one.consumer.reserve.model.item.AreaItem;
import com.one.consumer.reserve.presenter.SelectAreaPresenter;
import com.one.consumer.reserve.ui.binder.QuestionBinder;

/**
 * author ：zhulunjun
 * email  ：zhulunjun@qq.com
 * date   ：2018/10/30 11:20 PM
 * description ：选择维修问题
 **/
@Route(path = RouterPath.SELECT_QUESTION)
public class SelectQuestionActivity extends BaseListActivityC<SelectAreaPresenter> implements IListView, QuestionBinder.AreaClickListener {
    private AreaExtra mExtra;

    @Override
    protected void initPresenter() {
        mPresenter = new SelectAreaPresenter(this, this);
    }

    @Override
    public void registerDate() {
        register(AreaItem.class, new QuestionBinder(this));
    }

    @Override
    public void loadData() {
        mExtra = (AreaExtra) getIntent().getSerializableExtra(AreaExtra.getExtraName());
        if (mExtra != null) {
            mPresenter.getAreaList(mExtra.getIds().get(1));
        }
    }

    @Override
    public void initData() {
        super.initData();
        loadData();
    }

    @Override
    protected void initTitle() {
        super.initTitle();
        getMyTitleBar().setMode(MyTitleBar.Mode.BACK_TITLE)
                .setTitleText("常见问题选择");
    }

    @Override
    public void onAreaClick(AreaItem item) {
        if (mExtra != null) {
            mExtra.getIds().add(item.getParts_id() + "");
            mExtra.getNames().add(item.getParts_name());
            Intent intent = new Intent();
            intent.putExtra(AreaExtra.getExtraName(), mExtra);
            setResult(AddServiceActivity.RESULT_AREA, intent);
            finishPage();
        }
    }

    @Override
    public boolean onEmpty() {
        return true;

    }
}
